package org.wishwork.api.base.wms;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import org.wishwork.api.Base;

/**
 * @description:
 * @author: WangYX
 * @create: 2022-04-02 17:05
 * @Version: 1.0.0
 **/
@EqualsAndHashCode
@Getter
@ToString
public class WmsRequest extends Base {

    private WmsRequest(Integer pageIndex, Integer pageSize) {
        super(pageIndex, pageSize);
    }

    @Override
    public Builder toBuilder() {
        return new Builder().pageIndex(this.pageIndex).pageSize(this.pageSize);
    }

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder extends Base.Builder<Builder, WmsRequest> {

        @Override
        public Builder pageIndex(Integer pageIndex) {
            this.pageIndex = pageIndex;
            return this;
        }

        @Override
        public Builder pageSize(Integer pageSize) {
            this.pageSize = pageSize;
            return this;
        }

        @Override
        public WmsRequest build() {
            this.pageIndex = this.pageIndex == null ? 1 : this.pageSize < 0 ? 1 : this.pageIndex;
            this.pageSize = this.pageSize == null ? 30 : this.pageSize < 0 ? 30 : this.pageSize;
            return new WmsRequest(this.pageIndex, this.pageSize);
        }
    }
}
